package cn.wuqingna.legendgem.gui.gemmanager

import cn.wuqingna.legendgem.gui.Gui
import taboolib.library.xseries.XMaterial
import taboolib.module.nms.ItemTag
import taboolib.module.nms.getItemTag
import taboolib.module.ui.ClickEvent
import taboolib.platform.util.isNotAir

object ProtectiveManager {
    fun clear(gui: Gui){
        gui.typeSlot["PROTECTIVE"]!!.forEach {
            gui.inventory!!.setItem(it, XMaterial.AIR.parseItem())
        }
        gui.protective = ""
        gui.protectItem = XMaterial.AIR.parseItem()!!
    }
    fun protective(event: ClickEvent, gui: Gui, tag: ItemTag){
        val protective = tag.getDeep("legendGem.gem-protective")
        if (protective != null&& gui.useItem.isNotAir()){
            val item =  event.clickEvent().currentItem
            gui.protective = protective.asString()
            gui.protectItem = item
            gui.typeSlot["PROTECTIVE"]!!.forEach {
                gui.inventory!!.setItem(it, item)
            }
        }
    }

}